<form action="#" method="post">
	<table>
		<tr>
			<td>Titre:</td>
			<td><input type="text" name="titre" value="<?php echo $titre; ?>"/></td>
		</tr>
		<tr>
			<td>Contenu:</td>
			<td><textarea id="contenu" name="contenu"><?php echo $contenu; ?></textarea></td>
		</tr>
		<tr>
			<td>Cat&eacute;gorie:</td>
			<td>
				<select name="categorie">
				<?php
					foreach($mainCategoriesList as $mainCat)
					{
						$tabCat[$mainCat->getIdCat()]= $mainCat->getNameCat();
						
	
						echo "<option value='".$mainCat->getIdCat()."'>".$mainCat->getNameCat()."</option>";
						
						$subcategoriesList = Category::listing("WHERE CAT_IdParent = ".$mainCat->getIdCat());
						
						foreach($subcategoriesList as $subCat)
						{
							$tabCat[$subCat->getIdCat()]= $subCat->getNameCat();
							if($idCat==$subCat->getIdCat())
								echo "<option value='".$subCat->getIdCat()."' selected='selected'>----".$subCat->getNameCat()."</option>";
							else
								echo "<option value='".$subCat->getIdCat()."'>----".$subCat->getNameCat()."</option>";
						}
					}
				?>
				</select>
			</td>
		</tr>
		<tr>
			<td>Statut:</td>
			<td>
				<select name="statut">
				<?php
				
					foreach($statusList as $status)
					{
						$tabStatus[$status->getIdStatus()]= $status->getNameStatus();
						if($idStatus==$status->getIdStatus())
							echo "<option value='".$status->getIdStatus()."' selected='selected'>".$status->getNameStatus()."</option>";
						else
							echo "<option value='".$status->getIdStatus()."' >".$status->getNameStatus()."</option>";
					}

					?>
				
				</select>
			</td>
		</tr>
		<tr>
			<td><input type="submit" value="<?php echo $bouton=isset($_POST['edit'])?"Editer":"Cr&eacute;er"; ?> "/></td>
		</tr>
		<input type='hidden' name='idEdit' value='<?php echo $id=isset($_POST['edit'])?$_POST['idArt']:NULL; ?>'/>
	</table>	
</form>




<hr>


<table>	
	<tr>
		<th>ID</th>
		<th>Titre</th>					
		<th>Date</th>
		<th>Cat&eacute;gorie</th>
		<th>Statut</th>					
	</tr>

<?php
foreach($articlesList as $article)
{
?>
<form method='post' action='#'>
	<tr>
		<td><?php echo $article->getIdArt()?></td>
		<td><?php echo  $article->getTitleArt()?></td>
		<td><?php echo $article->getDateArt()?></td>
		<td><?php echo  $tabCat[$article->getIdCategoryArt()]?></td>
		<td><?php echo  $tabStatus[$article->getIdStatusArt()]?></td>
		<td><input type="submit" name="edit" value="Editer"></td>
		<td><input type="submit" name="suppr" value="Supprimer"></td>
	</tr>
	<input type="hidden" name="idArt" value="<?php echo $article->getIdArt()?>" />
</form>
<?php
}

echo "</table>";
			

?>